package net.etao.ds;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class OllamaChatController {
    
    private final ChatClient chatClient;

    public OllamaChatController(@Qualifier("ollamaChatClient") ChatClient chatClient) {
        this.chatClient = chatClient;
    }

    @GetMapping("/ollama")
    public String ollama() {
        return chatClient.prompt()
        .user("英文单词Strawberry中有几个字母r")
        .call()
        .content();
    }

    @GetMapping("/ollama-stream") 
    public Flux<String> ollamaStream() {
        return chatClient.prompt()
        .user("英文单词Strawberry中有几个字母r")
        .stream() 
        .content();
    }
    
}
